package XynLeen.GraduationProject.Fragments.Tools;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.CardView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import org.litepal.crud.DataSupport;

import XynLeen.GraduationProject.Activities.Activity_Album_Add;
import XynLeen.GraduationProject.Activities.Activity_Arrangement;
import XynLeen.GraduationProject.Activities.Activity_Bills;
import XynLeen.GraduationProject.Activities.Activity_Calendar;
import XynLeen.GraduationProject.Activities.Activity_Invitation;
import XynLeen.GraduationProject.Activities.Activity_Album;
import XynLeen.GraduationProject.Activities.Activity_Schedule;
import XynLeen.GraduationProject.BackPress.BaseFragment;
import XynLeen.GraduationProject.Bean.TypeBean;
import XynLeen.GraduationProject.R;

public class FragmentB extends BaseFragment implements View.OnClickListener {

    private CardView card_1;
    private CardView card_2;
    private CardView card_3;
    private CardView card_4;
    private CardView card_5;
    private CardView card_6;

    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_b,container,false);

        card_1=(CardView) view.findViewById(R.id.card_1);
        card_1.setRadius(20);//设置图片圆角的半径大小
        card_1.setCardElevation(20);//设置阴影部分大小
        card_1.setContentPadding(5,5,5,5);//设置图片距离阴影大小

        card_2=(CardView) view.findViewById(R.id.card_2);
        card_2.setRadius(20);//设置图片圆角的半径大小
        card_2.setCardElevation(20);//设置阴影部分大小
        card_2.setContentPadding(5,5,5,5);//设置图片距离阴影大小

        card_3=(CardView) view.findViewById(R.id.card_3);
        card_3.setRadius(20);//设置图片圆角的半径大小
        card_3.setCardElevation(20);//设置阴影部分大小
        card_3.setContentPadding(5,5,5,5);//设置图片距离阴影大小

        card_4=(CardView) view.findViewById(R.id.card_4);
        card_4.setRadius(20);//设置图片圆角的半径大小
        card_4.setCardElevation(20);//设置阴影部分大小
        card_4.setContentPadding(5,5,5,5);//设置图片距离阴影大小

        card_5=(CardView) view.findViewById(R.id.card_5);
        card_5.setRadius(20);//设置图片圆角的半径大小
        card_5.setCardElevation(20);//设置阴影部分大小
        card_5.setContentPadding(5,5,5,5);//设置图片距离阴影大小

        card_6=(CardView) view.findViewById(R.id.card_6);
        card_6.setRadius(20);//设置图片圆角的半径大小
        card_6.setCardElevation(20);//设置阴影部分大小
        card_6.setContentPadding(5,5,5,5);//设置图片距离阴影大小

        card_1.setOnClickListener(this);
        card_2.setOnClickListener(this);
        card_3.setOnClickListener(this);
        card_4.setOnClickListener(this);
        card_5.setOnClickListener(this);
        card_6.setOnClickListener(this);
        return view;
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.card_1:
                startActivity(new Intent(getActivity(), Activity_Bills.class));
                break;
            case R.id.card_2:
                startActivity(new Intent(getActivity(), Activity_Invitation.class));
                break;
            case R.id.card_3:
                //不加判断会加载不了没有数据时的页面？？？
                int id=DataSupport.sum(TypeBean.class,"id",int.class);
                //Log.e("shuju",String.valueOf(id));
                if (id!=0){
                    startActivity(new Intent(getActivity(), Activity_Album.class));
                    break;
                }else if(id==0){
                    startActivity(new Intent(getActivity(), Activity_Album_Add.class));
                    break;
                }
                break;
            case R.id.card_4:
                startActivity(new Intent(getActivity(), Activity_Calendar.class));
                break;
            case R.id.card_5:
                startActivity(new Intent(getActivity(), Activity_Schedule.class));
                break;
            case R.id.card_6:
                startActivity(new Intent(getActivity(), Activity_Arrangement.class));
                break;
            default:
                break;
        }
    }

}
